// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   CourseRequestsDAO.java

package com.nervytech.tutorcruise.db.dao.mysql.impl;

import com.nervytech.tutorcruise.db.dao.interfaces.ICourseRequestsDAO;
import com.nervytech.tutorcruise.db.dao.model.CourseRequests;

import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

@Repository("courseRequestsDAO")
public class CourseRequestsDAO extends JdbcDaoSupport implements
		ICourseRequestsDAO {

	@Autowired
	CourseRequestsDAO(DataSource dataSource) {
		setDataSource(dataSource);
	}

	public void saveCourseRequest(CourseRequests req) {
		Map argsMap = new HashMap();
		argsMap.put("user_id", Long.valueOf(req.getUserId()));
		argsMap.put("title", req.getTitle());
		argsMap.put("expecetd_satrt_date", req.getExpecetdStartDate());
		argsMap.put("duration", Double.valueOf(req.getDuration()));
		argsMap.put("level", Integer.valueOf(req.getLevel()));
		argsMap.put("course_type", Integer.valueOf(req.getCourseType()));
		argsMap.put("training_type", Integer.valueOf(req.getTrainingType()));
		argsMap.put("experience_required",
				Integer.valueOf(req.getExperienceRequired()));
		argsMap.put("category", Integer.valueOf(req.getCategory()));
		argsMap.put("skill_sets", req.getSkillSets());
		argsMap.put("expected_content", req.getExpectedContent());
		argsMap.put("attendees_content",
				Integer.valueOf(req.getAttendeesCount()));
		argsMap.put("notes", req.getNotes());
		argsMap.put("status", req.getUpdatedTime());
		argsMap.put("created_time", req.getCreatedTime());
		argsMap.put("updated_time", req.getUpdatedTime());
		long requestId = (new SimpleJdbcInsert(getJdbcTemplate()))
				.withTableName("course_requests")
				.usingGeneratedKeyColumns(new String[] { "requests_id" })
				.executeAndReturnKey(argsMap).longValue();
		req.setRequestId(requestId);
	}
}
